<!DOCTYPE html>
<html>
<meta charset="UTF-8"/>
<head>
	<title>创建a标签</title>
</head>
<body>
<script type="text/javascript">



	window.onload=function(){

		var oBody=document.getElementsByTagName('body')[0];
		var text_A=document.getElementsByTagName('a');
		// var textA=document.createEment('a');

		for(var i=0; i<10;i++){
			var textA=document.createElement('a');
			
			oBody.appendChild(textA);
			text_A[i].index = i;
			text_A[i].innerHTML=i+'</br>'+"</br>";
			text_A[i].style.color='red';
			text_A[i].style.fontSize = "24px";
			text_A[i].addEventListener('click',function(e){
				var otarget = e.target;
				// console.log(this.index);
				alert(this.index);
			})

		}
		console.log(text_A)



	}

</script>

</body>
</html>